/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.perlak.camel;

import com.perlak.logs.LoggingClass;
import org.apache.camel.builder.RouteBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author mateusz
 */
public abstract class BaseRouteBuilder extends RouteBuilder implements LoggingClass {

  /**
   * Delay pattern constant.
   */
  public static final String DEFAULT_DELAY_PATTERN = "2:1000;5:10000";
  /**
   * Dead letter queue prefix.
   */
  public static final String DEAD_QUEUE_PREFIX = "dead.";
  /**
   * In queue postfix.
   */
  public static final String IN_POSTFIX = ".in";
  /**
   * Out queue postfix.
   */
  public static final String OUT_POSTFIX = ".out";
  /**
   * Constant for jms queue.
   */
  public static final String JMS = "jms:";
  /**
   * Replay part for inout queue name
   */
  public static final String REPLY_PART = "?requestTimeout=240000&replyTo=";

  /**
   * Creates inout queue name with reply to output queue for request-reply communication.
   * @param baseQueueName base queue name.
   * @return returns JNDI name with reply parameter.
   */
  protected static String getInOutQueue(final String baseQueueName) {
    return JMS + Queues.BASE_PREDICATE + baseQueueName + IN_POSTFIX + REPLY_PART + baseQueueName + OUT_POSTFIX;
  }

  /**
   * Gets dead queue name from base queue name.
   * @param baseQueueName base queue name
   * @return dead queue name
   */
  protected static String getDeadQueue(final String baseQueueName) {
    return JMS + Queues.BASE_PREDICATE + DEAD_QUEUE_PREFIX + baseQueueName;
  }

  /**
   * Gets queue name from base queue name.
   * @param baseQueueName base queue name
   * @return full queue name
   */
  protected static String getQueue(final String baseQueueName) {
    return JMS + Queues.BASE_PREDICATE + baseQueueName;
  }

  /**
   * Gets out queue name from base queue name.
   * @param baseQueueName base queue name
   * @return out queue name
   */
  protected static String getOutQueue(final String baseQueueName) {
    return JMS + Queues.BASE_PREDICATE + baseQueueName + OUT_POSTFIX;
  }

  /**
   * Gets in queue name from base queue name.
   * @param baseQueueName base queue name
   * @return in queue name
   */
  protected static String getInQueue(final String baseQueueName) {
    return JMS + Queues.BASE_PREDICATE + baseQueueName + IN_POSTFIX;
  }

  /**
   * Creates inout queue name with reply to output queue for request-reply communication.
   * @param inputQueueName input queue name.
   * @param outputQueueName reply to queue name - output.
   * @return returns JNDI name with reply parameter.
   */
  protected static String getInOutQueue(final String inputQueueName, final String outputQueueName) {
    return JMS + Queues.BASE_PREDICATE + inputQueueName + REPLY_PART + outputQueueName;
  }
}
